<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>

<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>

<xsl:template match='nbsp' name='nbsp'>
<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>
</xsl:template>

<xsl:template match="nomore">
<table bgcolor="#f4efdf" class="nbox" border="0" cellspacing="0" cellpadding="4" width="100%">
<tr bgcolor="#f4ebce"><td height="25px"><b>Hai gia' risposto a tutti i test!</b></td></tr>
<tr bgcolor="#787878" height="1px"><td></td></tr>
<xsl:for-each select="iTest">
<tr><td align="center"><a href="/tests/iTestResults.aspx?pollid={@form}"><xsl:value-of select="@title"/></a></td></tr>
</xsl:for-each>
</table>
</xsl:template>

<xsl:template match="iTest">

		<table class="body" border="0" cellspacing="0" cellpadding="0" width="100%" >
		<tr>
		<td width="15px" height="15px"><img src="/imgs/gallery/ctsx.gif"/></td>
		<td bgcolor="#EEC867">&#160;</td>
		<td width="15px" height="15px"><img src="/imgs/gallery/ctdx.gif"/></td>
		</tr>
		<tr>
		<td bgcolor="#EEC867" width="15px" height="15px"></td>
		<td bgcolor="#EEC867">
		
<table class="body" border="0" cellspacing="0" cellpadding="4" width="100%">
<tr><td colspan="2" height="25px" >
<center><b><xsl:value-of select="@question"/></b></center>
</td></tr>
<tr><td colspan="2" height="25px" style="border-top: 1px solid #F7F7F7;">
<center><b>Risultati:</b></center>
</td></tr>
<xsl:for-each select="iTestResult">
<tr>
	<td width="50%" align="right"><xsl:value-of select="@phits"/>%</td>
	<td width="50%"><xsl:value-of select="@answer"/></td>
</tr>
</xsl:for-each>
<tr>
	<td colspan="2" align="center" style="font-size:8pt;">(<xsl:value-of select="/iTest/@hits"/> voti)</td>
</tr>
</table>

		</td>
		<td bgcolor="#EEC867" width="15px" height="15px"></td>
		</tr>
		<tr>
		<td width="15px" height="15px"><img src="/imgs/gallery/cbsx.gif"/></td>
		<td bgcolor="#EEC867">&#160;</td>
		<td width="15px" height="15px"><img src="/imgs/gallery/cbdx.gif"/></td>
		</tr>
		</table>

</xsl:template>

<xsl:template match="Registration">

<table bgcolor="#EEEEEE" class="body_10px" border="0" cellspacing="4" cellpadding="0" width="100%">
<form name="formRegistration" method="post" action="{@action}">
<tr>
<input type="hidden" name="FORM_ID" value="{@ID}"></input>
<td colspan="4">
</td>
</tr>

<xsl:variable name="nextForm">
<xsl:for-each select="Question">
<xsl:choose>
	<xsl:when test='@Type="16"'>
			<xsl:value-of select="@P1"/>
	</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:variable>

<xsl:for-each select="Question">
<xsl:choose>
	<xsl:when test='@Type="8"'>
		<tr><td colspan="4" align="center">
		<input type="hidden" name="qTotal" value="{/Registration/@qTotal}"></input>
		<input type="hidden" name="yTotal" value="{/Registration/@yTotal}"></input>
		<input type="hidden" name="nextForm" value="{$nextForm}"></input>
		<br/><input type="submit" name="{concat('SUBMIT',@ID)}" value="{@Description}"></input><br/>
		</td></tr>
	</xsl:when>
	<xsl:otherwise>
		<tr><td><xsl:value-of select="@Description"/></td></tr>
		<tr>
		<td>

		<xsl:if test='@Type="2"'>
		<table>
		<xsl:variable name="radioID" select="concat('R',@ID)"></xsl:variable>

		<xsl:choose>
		<xsl:when test='@P1="1"'>
			<tr>
			<xsl:for-each select="Answer">
				<xsl:choose>
				  <xsl:when test='@Selected="1"'><td><input type="radio" checked="yes" value="{.}" name="{$radioID}"></input></td></xsl:when>
				  <xsl:when test='@Selected="0"'><td><input type="radio" value="{.}" name="{$radioID}"></input></td></xsl:when>
				</xsl:choose>
				<td class="body_10px"><xsl:value-of select="."/></td>
			</xsl:for-each>
			</tr>
		</xsl:when>
		<xsl:when test='@P1="2"'>
			<xsl:for-each select="Answer">
				<tr>
					<xsl:choose>
					  <xsl:when test='@Selected="1"'><td><input type="radio" checked="yes" value="{@ID}" name="{$radioID}"></input></td></xsl:when>
					  <xsl:when test='@Selected="0"'><td><input type="radio" value="{@ID}" name="{$radioID}"></input></td></xsl:when>
					</xsl:choose>
				<td class="body_10px"><xsl:value-of select="."/></td>
				</tr>
			</xsl:for-each>
		</xsl:when>
		</xsl:choose>

		</table>
		</xsl:if>

		</td>
		</tr>
	</xsl:otherwise>
</xsl:choose>

</xsl:for-each>


</form>
</table>
		
</xsl:template>

</xsl:stylesheet>